//package com.bingquan.company.excel;
//
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletResponse;
//import java.io.*;
//
//@RestController
//@RequestMapping("/test")
//@Api("测试集成Swagger")
//public class DownloadExcel {
//
//    @GetMapping("/downloadByPath")
//    public void downloadByPath(String path,  HttpServletResponse response) {
//
//        String localPath = this.applicationProperties.getFile().getLocalDiskPath();//application.yml中配置的路径
//
//        FileInputStream fs = null;
//        OutputStream os = null;
//        try {
//            File file = new File(localPath + "/"+ path);
//            fs = new FileInputStream(file);
//            String fileName = file.getName();
//            byte[] buffer = new byte[fs.available()];
//            fs.read(buffer);
//            response.reset();
//            response.addHeader("Content-Disposition", "attachment;filename=" + new String(fileName.getBytes(),"iso-8859-1"));
//            response.addHeader("Content-Length", "" + file.length());
//            os = new BufferedOutputStream(response.getOutputStream());
//            response.setContentType("application/octet-stream");
//            os.write(buffer);
//        } catch (FileNotFoundException | UnsupportedEncodingException e) {
//            e.printStackTrace();
//        } catch (IOException e) {
//            e.printStackTrace();
//        }finally {
//            try {
//                fs.close();
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//            try {
//                os.flush();
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//            try {
//                os.close();
//            } catch (IOException e) {
//                e.printStackTrace();
//            }
//        }
//    }
//
//}
